package com.xzzz.irda.guardcat.core.metric;

import com.xzzz.irda.guardcat.core.metric.app.DubboRelationUtil;
import com.xzzz.irda.guardcat.core.metric.app.FeignRelationUtil;
import com.xzzz.irda.guardcat.core.metric.app.GatewayRelationUtil;
import com.xzzz.irda.guardcat.core.metric.rocketmq.RocketMQMetricConfiguration;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import java.util.HashMap;
import java.util.Map;

/**
 * 【Core】应用调用关系
 *
 * @author xzzz
 */
@RestController
@RequestMapping("/guardcat/core/app")
public class GuardcatAppRelationController {

    @Autowired(required = false)
    private RocketMQMetricConfiguration rocketMQMetricConfiguration;

    /**
     * 应用调用关系信息
     *
     * @return diaoyon
     */
    @GetMapping("/relation")
    public Map<String, Object> getRelation() {
        Map<String, Object> map = new HashMap<>();
        map.put("rpcRelation", DubboRelationUtil.getRelation());
        map.put("feignRelation", FeignRelationUtil.getRelation());
        map.put("gateway", GatewayRelationUtil.getRelation());
        map.put("rocketmq", rocketMQMetricConfiguration != null);
        return map;
    }
}
